/**  
 * @Title: AdminValidator.java
 * @Package com.limit.control.admin.validate
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-2 下午05:53:37
 * @version V1.0
 */ 
package com.limit.control.admin.validate;

import java.util.List;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.limit.model.Actor;
import com.limit.model.Admin;

/** 
 * <br/>
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-2 下午05:53:37 
 * @version V1.0
 */

public class AdminValidator extends Validator {

	/* 
	 * 
	 * @param c 
	 * @see com.jfinal.validate.Validator#validate(com.jfinal.core.Controller) 
	 */
	@Override
	protected void validate(Controller c) {
		this.validateRequired("admin.actor_id", "actor_idError", "关联角色ID不能为空！");
		this.validateRequired("admin.nickname", "nicknameError", "昵称不能为空！");
		this.validateRequired("admin.username", "usernameError", "登陆名不能为空！");
		this.validateRequired("admin.password", "passwordError", "密码不能为空！");
//		this.validateRequired("admin.phone", "phoneError", "座机不能为空！");
//		this.validateRequired("admin.telephone", "telephoneError", "手机不能为空！");
//		this.validateRequired("admin.email", "emailError", "邮箱不能为空！");
		this.validateRequired("admin.disable", "disableError", "是否禁用不能为空！");
		
	}

	/* 
	 * 
	 * @param c 
	 * @see com.jfinal.validate.Validator#handleError(com.jfinal.core.Controller) 
	 */
	@Override
	protected void handleError(Controller c) {
		
		c.keepModel(Admin.class);
		List<Actor> actors = Actor.dao.getAllList();
		c.setAttr("actors", actors);
		c.render("admin_view.html");
		
		
	}

}
